package com.kedacom.freedomLabel.model.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.kedacom.freedomLabel.model.bean.Category;

import java.util.List;

/**
 * @author licheng
 * @since 2019/11/20 17:02
 */
@Dao
public interface CategoryDao extends IDao<Category> {

    @Override
    @Query("SELECT COUNT(0) FROM Category")
    int count();

    @Override
    @Update
    void update(Category category);

    @Override
    @Insert(onConflict = OnConflictStrategy.FAIL)
    long save(Category category);

    @Override
    @Insert(onConflict = OnConflictStrategy.FAIL)
    long[] save(List<Category> data);

    @Override
    @Query("SELECT * FROM CATEGORY ORDER BY createTime")
    List<Category> get();

    @Override
    @Query("SELECT * FROM CATEGORY WHERE name =:param ORDER BY createTime")
    List<Category> get(String param);

    @Override
    @Query("SELECT * FROM CATEGORY WHERE uuid =:uuid AND name =:name")
    List<Category> get(String uuid, String name);

    @Override
    @Delete
    void delete(Category data);

    @Override
    @Query("DELETE FROM CATEGORY")
    void delete();

    @Override
    @Query("DELETE FROM Category WHERE name =:category")
    void delete(String category);

}